Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gradle toolchains to build ORT with a consistent Java version #8411

Merged
merged 5 commits into from
Mar 14, 2024

Conversation

sschuberth
Copy link
Member

Please have a look at the individual commit messages for the details.

The bogus warning from [1] cannot be reproduced anymore when running

    ./gradlew --rerun-tasks --no-build-cache --no-configuration-cache \
        :buildSrc:build

[1]: https://youtrack.jetbrains.com/issue/KT-48745

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth requested a review from a team as a code owner March 13, 2024 22:34
@sschuberth sschuberth force-pushed the use-gradle-toolchains branch 2 times, most recently from 30e85e1 to 49c08db Compare March 14, 2024 07:18
The previous code was calling `JavaVersion.current()` at build time,
assuming that the Java version running Gradle is the same Java version
used for building ORT. This assumption makes it more difficult to build
ORT for different Java versions in the same environment. Solve that by
using Gradle's toolchains mechanism [1] instead.

Choose Java 11 as the default for the new `javaLanguageVersion` property
to support analyzing older projects with ORT, also see [2].

[1]: https://docs.gradle.org/current/userguide/toolchains.html
[2]: #8249

Signed-off-by: Sebastian Schuberth <[email protected]>
Ensure to get values in exactly the same way as main ORT itself does.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth force-pushed the use-gradle-toolchains branch from 49c08db to 93a7f37 Compare March 14, 2024 07:19
@@ -23,6 +23,9 @@ org.gradle.parallel = true

kotlin.code.style = official

# The version of the JDK to use for building ORT.
javaLanguageVersion = 11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I'd be fine with giving this another / shorter name. Maybe just buildJdk?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either name, but add javaToolchainVersion to the candidates.

@sschuberth
Copy link
Member Author

Based on this, we could also do some simplifications regarding the GitHub workflows and Docker images, but I'll do these separately as a follow-up.

@@ -23,6 +23,9 @@ org.gradle.parallel = true

kotlin.code.style = official

# The version of the JDK to use for building ORT.
javaLanguageVersion = 11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either name, but add javaToolchainVersion to the candidates.

@sschuberth sschuberth merged commit fad4d5e into main Mar 14, 2024
21 checks passed
@sschuberth sschuberth deleted the use-gradle-toolchains branch March 14, 2024 08:34
@sschuberth
Copy link
Member Author

I'll do these separately as a follow-up.

See #8414 for a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants